//
//  ChooseGiftCollectionViewCell.m
//  ChooseGift
//
//  Created by lanou on 15/12/16.
//  Copyright (c) 2015年 lanou. All rights reserved.
//
#define kwidth [UIScreen mainScreen].bounds.size.width

#import "ChooseGiftCollectionViewCell.h"
@implementation ChooseGiftCollectionViewCell

- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        _mainImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0,kwidth / 2 - 15, kwidth / 2 - 13.5)];
        _titleLable = [[UILabel alloc]initWithFrame:CGRectMake(15, kwidth / 2 - 15 , kwidth / 2 - 40, 60)];
        _titleLable.font = [UIFont systemFontOfSize:15];
        _titleLable.textColor = [UIColor darkGrayColor];
        _titleLable.numberOfLines = 0;
        
        _moneyLable = [[UILabel alloc]initWithFrame:CGRectMake(10, self.mainImage.frame.size.height + 56 , 100, 20)];
        _moneyLable.font = [UIFont systemFontOfSize:16];
        _moneyLable.textColor = kThemeColor;
        
        _heartImage = [[UIImageView alloc]initWithFrame:CGRectMake(self.mainImage.frame.size.width - 70 , self.mainImage.frame.size.height + 60, 15, 15)];
        _numLable = [[UILabel alloc]initWithFrame:CGRectMake(self.heartImage.frame.origin.x + 20, self.mainImage.frame.size.height + 57, 60, 20)];
        _numLable.font = [UIFont systemFontOfSize:15];
        _numLable.textColor = [UIColor darkGrayColor];
        
        [self.contentView addSubview:_mainImage];
        [self.contentView addSubview:_titleLable];
        [self.contentView addSubview:_moneyLable];
        [self.contentView addSubview:_heartImage];
        [self.contentView addSubview:_numLable];
        
        self.layer.cornerRadius = 5;
        self.layer.masksToBounds = YES;
        
        
    }
    return self;
}


- (void)setChoose:(ChooseGift *)choose{
    if (_choose != choose) {
        _choose = choose;
        self.mainImage.image = [UIImage imageNamed:@"zhanweipic.png"];
        NSURL *url = [NSURL URLWithString:choose.cover_image_url];
//        NSData *data = [NSData dataWithContentsOfURL:url];
//        self.mainImage.image = [UIImage imageWithData:data];
        
        [self.mainImage sd_setImageWithURL:url];
        self.titleLable.text = choose.name;
        NSString *money = [NSString stringWithFormat:@"¥%@",choose.price];
        self.moneyLable.text = money;
        self.heartImage.image = [UIImage imageNamed:@"赞_touch-28px.png"];
        
        self.numLable.text = choose.favorites_count;
        
    }
}














@end
